import React, { useEffect, useState } from 'react'

export default function StrictCom() {
  console.log('222')
  //声明状态
  let [count, setCount] = useState(0);
  //useEffect
  useEffect(() => {
    let timer = setInterval(() => {
      //更新状态
      setCount(count => count + 1);
    }, 1000);
    //清理定时器
    return () => {
      clearInterval(timer);
    }
  }, [])

  return (
    <div>
      <h2>{count}</h2>
    </div>
  )
}
